<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href="${resources}/plugins/fontAwesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="${resources}/plugins/swiper/3.3.1/swiper.min.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/sm.min.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/common.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/addaddress.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
    <!--头部-->
    <div class="commonHeader">我的地址
        <a href="javascript:history.go(-1);" class="fa fa-chevron-left back"></a>
    </div>
	
	<form action="${path}/manage/address/create?prevurl=${prevurl}&type=${type}"  method="post" id="addressForm">
    <table class="list">
        <tr>
            <td><label for="name">收货人</label></td>
            <td><input type="text" id="name" name="name" placeholder="请输入收货人姓名"></td>
        </tr>
        <tr>
            <td><label for="phone">联系电话</label></td>
            <td><input type="text" id="telephone" name="telephone" placeholder="请输入收货人联系电话"></td>
        </tr>
        <tr>
            <td><label for="phone">所在地区</label></td>
            <td><input type="text" id="address" name="address" placeholder="请选择"/></td>
        </tr>
        <tr>
            <td><label for="phone">是否默认</label></td>
            <td>
            	是 <input name="isDefault" id="isDefault" type="radio" checked="checked" value="1">
            	否 <input name="isDefault" id="isDefault" type="radio" value="0">
            </td>
        </tr>
        <tr>
            <td colspan="2"><textarea id="street"  name="street" placeholder="请填写详细地址，不少于5个字"></textarea></td>
        </tr>
    </table>

    <div class="bottomBtn">
        <a href="javascript:submitForm();">保存地址</a>
    </div>
	</form>
	
</div>

<script src="${resources}/js/zepto.min.js"></script>
<script src="${resources}/js/sm.min.js"></script>
<script src="${resources}/js/sm-city-picker.min.js"></script>
<script src="${resources}/js/zepto-common.js"></script>
<script>
    $("#address").cityPicker({
        toolbarTemplate: '<header class="bar bar-nav">\
    <button class="button button-link pull-right close-picker">确定</button>\
    <h1 class="title">选择收货地址</h1>\
    </header>'
    });
    
    function submitForm(){
    	var name=$("#name").val();
    	var telephone=$("#telephone").val();
    	var address=$("#address").val();
    	var street = $("#street").val();
    	
    
    	
    	if(name==""){
    		common.alert({
		   		width:"60%",
			   	title:"提示信息",
			 	content:"收货人不能为空!"
		   	})
    	}else if(telephone==""){
    		common.alert({
		   		width:"60%",
			   	title:"提示信息",
			 	content:"联系电话不能为空!"
		   	})
    	}else if(!/^1[34578]\d{9}$/i.test(telephone)){
			common.alert({
		   		width:"60%",
			   	title:"提示信息",
			 	content:"联系电话格式不正确!"
		   	})
		}else if(address==""){
    		common.alert({
		   		width:"60%",
			   	title:"提示信息",
			 	content:"所在地区不能为空!"
		   	})
    	}else if(street=='' || street.length<5){
    		common.alert({
		   		width:"60%",
			   	title:"提示信息",
			 	content:"详细地址不少于5个字!"
		   	})
    	}else if(name!=""&&/^1[34578]\d{9}$/i.test(telephone)&&address!=""){
    		$("#addressForm").submit();
    	}
    	
    }
</script>
</body>
</html>